#!/bin/sh
export runlevel=S
export PATH=/bin:/sbin:/mbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/local/xbin:/extd/bin:/root:/data
export LD_LIBRARY_PATH=/lib:/mlib:/usr/lib:/usr/local/lib:/extd/lib:/root:/data

/bin/mount -t proc  proc  /proc
/bin/mount -t sysfs sysfs /sys
/bin/mount -t tmpfs tmpfs /run
/bin/mount -t ramfs /tmp
/bin/mount -t ramfs /mnt

if [ ! -d /dev/pts ]; then
	mkdir /dev/pts
fi
mount -t devpts devpts  /dev/pts 

if [ ! -d /var ]; then
	mkdir -p /var
fi


/bin/rm -rf /var/run
/bin/ln -s  /run /var/run
/bin/mkdir -p /var/run/vsftpd/empty

if [ ! -d /var/log ]; then
	mkdir -p /var/log
fi
/bin/echo "init" > /var/log/login.log

if [ ! -f /var/log/vsftpd.log ]; then
	/bin/touch /var/log/vsftpd.log
fi

if [ -e /etc/init.d/rc.local ]; then
	/etc/init.d/rc.local
fi

/bin/echo > /dev/mdev.seq
/bin/echo /bin/mdev > /proc/sys/kernel/hotplug
/bin/mdev -s

if [ ! -d /root/etc ]&&[ -d /reset/root/etc ]; then
	cp -rf /reset/root/etc /root/
fi

if [ ! -d /root/eth0 ]&&[ -d /reset/root/eth0 ]; then
	cp -rf /reset/root/eth0 /root/
fi

hostnamestr=$(cat /etc/hostname)
/bin/hostname ${hostnamestr}

#检索执行前置初始化脚本
for i in /etc/init.d/S??* ;do
	[ ! -f "$i" ] && continue
	case "$i" in
		*.sh)
			(
			trap - INT QUIT TSTP
			set start
			. $i > /dev/null 2>&1
			)
			;;
		*)
			$i start >/dev/null 2>&1
			;;
	esac
done

#检索执行用户初始化脚本
if [ -d /root/init ]; then
	for i in /root/init/S??* ;do
		[ ! -f "$i" ] && continue
		case "$i" in
			*.sh)
				(
				trap - INT QUIT TSTP
				set start
				. $i > /dev/null 2>&1
				)
				;;
			*)
				$i start >/dev/null 2>&1
				;;
		esac
	done
fi
